import axios from 'axios'

interface Product {
  id: number
  image: string
  name: string
  price: number
  sales: number
  comments: number
  isAd: boolean
}

interface PaginationResult {
  list: Product[]
  total: number
  page: number
  pageSize: number
}

export const getProductsByPageDTO = (params: {
  category: string
  page: number
  pageSize: number
}): Promise<PaginationResult> => {
  console.log('Request params:', params);
  const requestData = {
    category: params.category,
    pageNo: params.page,
    pageSize: params.pageSize
  };
  console.log('Request data:', requestData);
  return axios.post('/xiaotao/products/page', requestData).then((res) => {
    return res.data as PaginationResult;
  })
}
